home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
util
/
pack
/
xpk_Source.lha
/
xpk_Source
/
xpkmaster
/
fib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-26
|
3KB
|
101 lines
#ifndef XPKMASTER_FIB_C
#define XPKMASTER_FIB_C
/* Routinesheader
Name: fib.c
Main: xpkmaster
Versionstring: $VER: fib.c 1.0 (05.10.96)
Author: SDI
Distribution: PD
Description: FIB related routines
1.0 05.10.96 : first real version
*/
#include <pragma/exec_lib.h>
#include <pragma/dos_lib.h>
#include <exec/types.h>
#include "xpkmaster.h"
void updatefib(struct XpkBuffer *xbuf)
{
struct XpkStreamHeader *globhdr = &xbuf->xb_Headers.h_Glob;
XpkChunkHeader *lochdr = &xbuf->xb_Headers.h_Loc;
struct XpkFib *fib = &xbuf->xb_Fib;
LONG ulen, clen;
#ifdef DEBUG
DebugRunTime("updatefib:start, %ld, %ld, %ld, %ld, %ld, %ld",
fib->xf_CLen, fib->xf_ULen, fib->xf_NLen, fib->xf_CCur, fib->xf_UCur);
#endif
if(xbuf->xb_Headers.h_Glob.xsh_Flags & XPKSTREAMF_LONGHEADERS)
{
ulen = lochdr->xch_Long.xchl_ULen;
clen = lochdr->xch_Long.xchl_CLen;
}
else
{
ulen = lochdr->xch_Word.xchw_ULen;
clen = lochdr->xch_Word.xchw_CLen;
}
fib->xf_Type = XPKTYPE_PACKED;
fib->xf_CLen = globhdr->xsh_CLen + 8;
fib->xf_ULen = globhdr->xsh_ULen;
fib->xf_NLen = ulen + XPK_MARGIN;
fib->xf_CCur += ROUNDLONG (clen) + xbuf->xb_Headers.h_LocSize;
fib->xf_UCur += ulen;
fib->xf_ID = globhdr->xsh_Type;
fib->xf_SubVersion = globhdr->xsh_SubVrs;
fib->xf_MasVersion = globhdr->xsh_MasVrs;
CopyMem(globhdr->xsh_Initial, fib->xf_Head, 16);
#ifdef DEBUG
DebugRunTime("updatefib:end, %ld, %ld, %ld, %ld, %ld, %ld",
fib->xf_CLen, fib->xf_ULen, fib->xf_NLen, fib->xf_CCur, fib->xf_UCur);
#endif
percentages(fib);
}
/*
void storefib (struct XpkBuffer *xbuf)
{
struct Headers globloc;
UBYTE comment[80];
STRPTR in = (STRPTR) &globloc, out = comment;
if (!xbuf->xb_OutName || !(xbuf->xb_Flags & XMF_USECOMMENT))
return;
CopyMem(&xbuf->xb_Headers, &globloc, sizeof(struct Headers));
globloc.h_LocSize = 0;
*(out++) = 'X'; *(out++) = 'P'; *(out++) = 'K'; *(out++) = 'F';
for(; in < (STRPTR) &globloc + sizeof(struct Headers) - 4; in += 3)
{
*out++ = 64 | (in[0] & 3) << 4 | (in[1] & 3) << 2 | in[0] & 3;
*out++ = 64 | in[0] >> 2;
*out++ = 64 | in[1] >> 2;
*out++ = 64 | in[2] >> 2;
}
*out = 0;
SetComment(xbuf->xb_OutName, comment);
}
*/
void percentages (struct XpkFib *fib)
{
fib->xf_Ratio = 0;
if(fib->xf_ULen)
fib->xf_Ratio = 100 - 100 * fib->xf_CLen / fib->xf_ULen;
if(fib->xf_Ratio < 0)
fib->xf_Ratio = 0;
*(LONG *) fib->xf_Packer = fib->xf_ID;
fib->xf_Packer[4] = 0;
}
#endif /* XPKMASTER_FIB_C */